package com.jingdianjichi.subject.common.entity;

import com.jingdianjichi.subject.common.enums.ResultCode;
import lombok.Data;

@Data
public class Result<T> {
    private Boolean success;
    private Integer code;
    private String message;
    private T data;

    public static<T> Result success(T data){
        Result result = new Result();
        result.setSuccess(true);
        result.setCode(ResultCode.SUCCESS.getCode());
        result.setMessage(ResultCode.SUCCESS.getDesc());
        result.setData(data);
        return result;
    }

    public static<T> Result error(T data){
        Result result = new Result();
        result.setSuccess(false);
        result.setCode(ResultCode.ERROR.getCode());
        result.setMessage(ResultCode.ERROR.getDesc());
        result.setData(data);
        return result;
    }
}
